package net.sxnic.workflow.task.action;

import net.sxnic.ugr.context.AppContext;
import net.sxnic.workflow.task.Task;

import org.apache.commons.lang.StringUtils;

@SuppressWarnings("serial")
public class CancelTask extends TaskAction {

	public String execute() throws Exception {

		if (StringUtils.isBlank(id)) {
			return INPUT;
		}

		task = taskManager.get(id);

		// 判断当前任务能否撤销
		if (!Task.TASK_STATUS_ENDED.equals(task.getStatus())) {
			msg = "withdrawNoEndedError";
			return INPUT;
		}
		// 判断后续任务是否已办
		boolean cancancel = taskManager.cancelTask(id,
				AppContext.getUserName(request));
		if (!cancancel) {
			msg = "withdrawNextTaskEndedError"; 
			return INPUT;
		}
		addLog("Cancelaction-taskid:" + id + "==文件办理==撤销====成功:" + task.getName());
		msg = "withdrawSuccess"; 
		return SUCCESS;

	}
}